<script setup>
import router from '../router/router'
import axios from 'axios'
import { onMounted, ref } from 'vue'
import { useRoute } from 'vue-router'
import { ElMessage } from 'element-plus'
const route = useRoute()
const id = ref(route.query.id)
const goBack = () => {
  router.push('/articleList')
}
const article = ref([])

onMounted(() => {
  axios.get('/api/mycontroller5/mymethod5/' + id.value).then((res) => {
    article.value = res.data
    console.log(article.value)
  })
})
const edit = () => {
  axios.get('/api/mycontroller10/mymethod10/' + id.value + '/' + article.value.mdcontent).then((res) => {
    article.value = res.data
    console.log(article.value)
    ElMessage.success('编辑成功')
  })
}
</script>

<template>
    <div style="text-align: left;">
        <el-button type="text"  @click="goBack" style="padding-bottom: 0px;"><el-icon><Back /></el-icon>返回</el-button>
    </div>

    <div class="title">
      {{article.title}}
    </div>

       <el-input
    v-model="article.mdcontent"
    autosize
    type="textarea"
    placeholder="Please input"
  />

    <div><button @click="edit">编辑成功</button></div>

</template>

<style scoped>
.title{
  font-size: 25px;
  font-weight: bold;
  text-align: center;
  margin-bottom: 30px;
}
.el-input{
  height: 800px;
}
</style>
